
import { registerClass } from "../../../cfw/tools/class_decorator";

import BaseAd from "../../core/base/BaseAd";
import Native, { NativeBannerAd } from "../../native/native";
import { SDKLogicState, SDKState } from "../../SDKDefine";
@registerClass('MiMoBannerAd')
export default class MiMoBannerAd extends BaseAd {
    hide(): void {
        throw new Error("Method not implemented.");
    }
    load(): void {
        throw new Error("Method not implemented.");
    }
    show(): void {
        throw new Error("Method not implemented.");
    }

    protected ad: NativeBannerAd;
    create() {
        if (!this.ad) {
            this.ad = this.sdk.createBannerAd({
                adUnitId: this.adUnitID,
                layout: 1,
                width: 300,
                height: 100
            })
            this.ad.onLoad(this.getFunc(this.onLoad))
            this.ad.onError(this.getFunc(this.onError))
        }
    }

    updateSize() {

    }

    onLoad() {
        this.setState(SDKState.loadSucess)
    }

    onError(err: any) {
        this.setState(SDKState.loadFail)
    }

    destroy(): void {
        if (this.ad) {
            this.ad.offLoad(this.getFunc(this.onLoad))
            this.ad.offError(this.getFunc(this.onError))
            this.ad = null;
        }
    }

}
